package com.shujia.jinjie;

import java.io.BufferedReader;
import java.io.FileReader;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.Arrays;
public class LoadData {
    public static void main(String[] args) throws Exception {
        Connection conn = MySqlTool.getConnection();
        PreparedStatement preparedStatement = conn.prepareStatement("insert into jd_goods(goods_name,price,comments,shop,icos) values(?,?,?,?,?)");

        BufferedReader br = new BufferedReader(new FileReader("redis/src/main/java/com/shujia/jinjie/jd_goods.txt"));

        String line = null;
        while ((line=br.readLine())!=null){
            if(line.endsWith(",")){
                line = line.concat("null");
            }
            System.out.println(line);

            String[] infos = line.split("\t");
//            System.out.println(Arrays.toString(infos));
//            System.out.println(infos[4]);
            preparedStatement.setString(1,infos[0]);
            preparedStatement.setString(2,infos[1]);
            preparedStatement.setString(3,infos[2]);
            preparedStatement.setString(4,infos[3]);
            preparedStatement.setString(5,infos[4]);

            preparedStatement.executeUpdate();
        }



    }
}
